home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / fioben.zip / CAT7.CPP < prev    next >
C/C++ Source or Header  |  1993-02-09  |  2KB  |  84 lines

  1. #include    <windows.h>
  2. #include    <iostream.h>
  3. #include    <iomanip.h>
  4. #include    <fstream.h>
  5. #include    <string.h>
  6.  
  7. ofstream    CERR("results.out", ios::app);
  8. int    BUFLEN = 0x10000;
  9.  
  10. ostream    & operator << (ostream & os, SYSTEMTIME & r)
  11. {
  12.     static    const char    * const rgszDayNames[] =
  13.         {
  14.         "Sunday",
  15.         "Monday",
  16.         "Tuesday",
  17.         "Wednesday",
  18.         "Thursday",
  19.         "Friday",
  20.         "Saturday",
  21.         0
  22.         };
  23.     char    chFill = os.fill();
  24.     os.fill('0');
  25.     os //--------------------------------- << rgszDayNames[r.wDayOfWeek] << ' '
  26.         << setw(2) << r.wMonth << '/'
  27.         << setw(2) << r.wDay << '/'
  28.         << setw(2) << r.wYear << ' '
  29.         << setw(2) << r.wHour << ':'
  30.         << setw(2) << r.wMinute << ':'
  31.         //------------------- << setw(2) << r.wSecond
  32.         ;
  33.     os.fill(chFill);
  34.     return    os;
  35. }
  36.  
  37. int main(int argc, char **argv)
  38. {
  39.     if (argc < 2)
  40.         {
  41.         cin.get(*cout.rdbuf(), EOF);
  42.         return    0;
  43.         }
  44.     SYSTEMTIME    sNow;
  45.     GetLocalTime(&sNow);
  46.     CERR << sNow << "===> " << GetCommandLine() << endl;
  47.  
  48.     char    *pBuf = new char[BUFLEN];
  49.     char    *pOut = new char[BUFLEN];
  50.  
  51.     ifstream    ifs;
  52.     delete [] ifs.setbuf(pBuf, BUFLEN);
  53.  
  54.     ofstream    ofs( ((filebuf *)cout.rdbuf())->fd(), pOut, BUFLEN);
  55.     if (!ofs)
  56.         {
  57.         CERR << "Error attaching output stream." << endl;
  58.         }
  59.  
  60.     DWORD    dwStart = GetTickCount();
  61.     
  62.     for (int iArg = 1; iArg < argc; iArg++)
  63.         {
  64.         ifs.open(argv[iArg], ios::in | ios::binary);
  65.         if (!ifs)
  66.             {
  67.             CERR << "Error opening input file: " << argv[iArg] << endl;
  68.             ifs.clear();
  69.             continue;
  70.             }
  71.         ifs.get(*ofs.rdbuf(), EOF);
  72.         ifs.close();
  73.         }
  74.     ofs.close();
  75.     dwStart = GetTickCount( ) - dwStart;
  76.      CERR << "**** Total time: " << (dwStart / 1000)
  77.         << '.' << (dwStart % 1000) << " seconds."
  78.         << endl;
  79.     delete    [] ifs.setbuf(0,0);
  80.     delete    [] ofs.setbuf(0,0);
  81.     return    0;
  82. }
  83.  
  84.